<?php
mysql_connect("localhost","root","");
mysql_select_db("chat");
$email=$_POST['email'];
$sql=mysql_query("SELECT u_email FROM users WHERE u_email ='$email'")or die(mysql_error()); 
	      $count=mysql_num_rows($sql);

$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['mobile'];
$pass=$_POST['password'];
$group=$_POST['group'];


if($count>0)
	{
		echo 'Email Already exists'; exit;
	}else


mysql_query("insert into users(u_name, u_email, u_phone, u_password, group_id) VALUES ('$name', '$email', '$phone', '$pass', '$group')")or die(mysql_error());
header("location:login.php?m=Ragister success please login");
?>